/**
 * Copyright (c) 2017-2024 Nop Platform. All rights reserved.
 * Author: canonical_entropy@163.com
 * Blog:   https://www.zhihu.com/people/canonical-entropy
 * Gitee:  https://gitee.com/canonical-entropy/nop-entropy
 * Github: https://github.com/entropy-cloud/nop-entropy
 */
package com.gitee.wsl.struct.table

import com.gitee.wsl.api.AbstractFreezable


/**
 * 在表格上定位的位置，例如图片在Excel表中的位置，图片的左上角和右下角都可能位于单元格的某个内部位置。 dx和dy的单位为pt
 */
class CellAnchor : AbstractFreezable() {
    var row1 = 0
    var col1 = 0
    var rowDelta = 1
    var colDelta = 1
    var dx1 = 0.0
    var dx2 = 0.0
    var dy1 = 0.0
    var dy2 = 0.0

    val col2: Int
        get() = col1 + colDelta

    val row2: Int
        get() = row1 + rowDelta

    /*protected fun copyTo(anchor: CellAnchor) {
        anchor.setRow1(getRow1())
        anchor.setCol1(getCol1())
        anchor.setRowDelta(getRowDelta())
        anchor.setColDelta(getColDelta())
        anchor.setDx1(getDx1())
        anchor.setDx2(getDx2())
        anchor.setDy1(getDy1())
        anchor.setDy2(getDy2())
    }*/


    fun row1(row1: Int): CellAnchor {
        this.row1=row1
        return this
    }

    fun rowDelta(rowDelta: Int): CellAnchor {
        this.rowDelta = rowDelta
        return this
    }

    fun colDelta(colDelta: Int): CellAnchor {
        this.colDelta = colDelta
        return this
    }

    fun dy2(dy2: Double): CellAnchor {
        this.dy2=dy2
        return this
    }
    fun dy1(dy1: Double): CellAnchor {
        this.dy1=dy1
        return this
    }

    fun dx2(dx2: Double): CellAnchor {
        this.dx2=dx2
        return this
    }

    fun col1(col1: Int): CellAnchor {
        this.col1=col1
        return this
    }

    fun dx1(dx1: Double): CellAnchor {
        this.dx1=dx1
        return this
    }
}